//
//  OrderStoreCell.m
//  KuWoCan
//
//  Created by hwd on 17/3/14.
//  Copyright © 2017年 hwd. All rights reserved.
//

#import "OrderStoreCell.h"

@interface OrderStoreCell ()

@property (nonatomic,strong) UILabel *oTimeParaLab;

@property (nonatomic,strong) UILabel *oStatusLab;

@property (nonatomic,strong) UIImageView *oStoreImgView;

@property (nonatomic,strong) UILabel *oStoreLab;

@property (nonatomic,strong) UILabel *oNumberLab;

@property (nonatomic,strong) UILabel *oTotalParaLab;

@end

@implementation OrderStoreCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        [self setUpUI];
    }
    return self;
}

- (void)setUpUI
{
    //分割线视图
    UIView *separatorView = [UIView new];
    separatorView.backgroundColor = KwColor(@"#eeeeee");
    [self addSubview:separatorView];
    [separatorView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.equalTo(@0);
        make.height.equalTo(@5);
    }];
    
    UILabel *oTimeConstLab = [UILabel new];
    oTimeConstLab.textColor = [UIColor grayColor];
    oTimeConstLab.font = [UIFont systemFontOfSize:13.0];
    oTimeConstLab.textAlignment = NSTextAlignmentLeft;
    oTimeConstLab.text = @"订单时间:";
    [self addSubview:oTimeConstLab];
    [oTimeConstLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@15);
        make.top.equalTo(separatorView.mas_bottom).offset(15);
        make.height.equalTo(@13);
    }];
    
    //parameter:订单时间
    _oTimeParaLab = [UILabel new];
    _oTimeParaLab.textColor = [UIColor grayColor];
    _oTimeParaLab.font = [UIFont systemFontOfSize:13.0];
    _oTimeParaLab.textAlignment = NSTextAlignmentLeft;
    _oTimeParaLab.text = @"2017-02-24 14:20";
    [self addSubview:_oTimeParaLab];
    [_oTimeParaLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(oTimeConstLab.mas_right).offset(10);
        make.top.equalTo(oTimeConstLab.mas_top);
        make.bottom.equalTo(oTimeConstLab.mas_bottom);
    }];
    
    //parameter:订单状态
    _oStatusLab = [UILabel new];
    _oStatusLab.textColor = [UIColor orangeColor];
    _oStatusLab.font = [UIFont systemFontOfSize:12.5];
    _oStatusLab.textAlignment = NSTextAlignmentRight;
    _oStatusLab.text = @"商品已发货";
    [self addSubview:_oStatusLab];
    [_oStatusLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(@-15);
        make.top.mas_equalTo(oTimeConstLab.mas_top);
        make.height.equalTo(oTimeConstLab.mas_height);
        make.width.equalTo(@100);
    }];
    
    UIView *lineView = [UIView new];
    lineView.backgroundColor = KwColor(@"#eeeeee");
    [self addSubview:lineView];
    [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(oTimeConstLab.mas_left);
        make.right.equalTo(@0);
        make.top.equalTo(oTimeConstLab.mas_bottom).offset(10);
        make.height.equalTo(@1.5);
    }];
    
    _oStoreImgView = [[UIImageView alloc] init];
    _oStoreImgView.image = [UIImage imageNamed:@"kuwo_logo"];
    [self addSubview:_oStoreImgView];
    [_oStoreImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@20);
        make.top.equalTo(lineView.mas_bottom).offset(17.5);
        make.height.width.equalTo(@58);
        make.bottom.equalTo(@-17.5);
    }];
    
    //parameter:商店名
    _oStoreLab = [UILabel new];
    _oStoreLab.textColor = [UIColor blackColor];
    _oStoreLab.font = [UIFont systemFontOfSize:17.5];
    _oStoreLab.textAlignment = NSTextAlignmentLeft;
    _oStoreLab.text = @"中百仓储光谷天地店";
    [self addSubview:_oStoreLab];
    [_oStoreLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(lineView.mas_bottom).offset(25);
        make.left.equalTo(_oStoreImgView.mas_right).offset(20);
        make.height.equalTo(@17);
        make.right.equalTo(@-30);
    }];
    
    //parameter:共多少见
    _oNumberLab = [UILabel new];
    _oNumberLab.textColor = [UIColor grayColor];
    _oNumberLab.font = [UIFont systemFontOfSize:14.0];
    _oNumberLab.textAlignment = NSTextAlignmentLeft;
    _oNumberLab.text = @"共50件商品";
    [self addSubview:_oNumberLab];
    [_oNumberLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_oStoreLab.mas_left);
        make.height.equalTo(@13);
        make.top.equalTo(_oStoreLab.mas_bottom).offset(10);
    }];
    
    //parameter:合记
    _oTotalParaLab = [UILabel new];
    _oTotalParaLab.textColor = [UIColor grayColor];
    _oTotalParaLab.font = [UIFont systemFontOfSize:14.0];
    _oTotalParaLab.textAlignment = NSTextAlignmentLeft;
    _oTotalParaLab.text = @"合计:￥3000.00";
    [self addSubview:_oTotalParaLab];
    [_oTotalParaLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_oNumberLab.mas_right).offset(20);
        make.height.equalTo(@13);
        make.top.equalTo(_oNumberLab.mas_top);
    }];
}

- (void)setModel:(OrderListModel *)model
{
    _oTimeParaLab .text = model.createDate;
    _oStatusLab.text = [Constants getOrderStatusWithApprovalType:model.approvalType orderStatus:model.orderStatus];
    _oStoreLab.text = model.userAddress;
    _oNumberLab.text = [NSString stringWithFormat:@"共%@件商品",model.totalBox];
    _oTotalParaLab.text = [NSString stringWithFormat:@"合计: ￥%@元",model.totalPrice];
}

@end
